import numpy as np

def random_det_matrix(check):
    if check == 0:
        A = np.random.randint(0, 9, 4)
        A = A.reshape(2, 2)
        return A
    if check == 1:
        A = np.random.randint(0, 9, 9)
        A = A.reshape(3, 3)
        return A
    if check == 2:
        A = np.random.randint(0, 9, 16)
        A = A.reshape(4, 4)
        return A

def solve_det_matrix(A):
    result = round(np.linalg.det(A),3)
    return result
if __name__ == '__main__':
    check_num = int(input('easy=0,'
                      'simple=1,'
                      'normal=2'))
    problems,answers = [],[]
    for i in range(0,1000):
        a = random_det_matrix(check_num)
        b = solve_det_matrix(a)
        problems.append(a)
        answers.append(b)
    reply = input('do you want to do det eval?y/n')
    for x in range(0, len(problems)):
        while reply != 'n':
            print(problems[x])
            your_answer = input('your answers\n')
            try :
                if int(answers[x]) == int(your_answer):
                    print("you are right")
                    reply = input('do you want to do more det eval?y/n')
                else:
                    print('you are wrong\n the answer is {}'.format(answers[x]))
                    reply = input('do you want to do more det eval?y/n')
            except:
                print('error')


